"use strict"
const nodemailer = require('nodemailer')
const { rejects } = require('assert')

//创建发送邮件的对象
let transporter = nodemailer.createTransport({
    host:"smtp.qq.com",
    port:465,
    secure:true,  //true for 465,false for other ports
    auth:{
        user:"1421826010@qq.com",//发送方的邮箱地址
        pass:"moumvypdwwazggig"
    }
})
/*
    发送邮件
*/
function send(mail,code){
    let mailobj = {
        from:'"skull"<1421826010@qq.com>', //sender address
        to:mail,
        subject:"验证码",
        text:`您的验证码是${code},请尽快处理`
    }
    return new Promise((resolve,reject)=>{
        transporter.sendMail(mailobj,(err,data)=>{
            if(err){
                reject()
            }else{
                resolve()
            }
        })
    })
    
}
module.exports = {send}